package com.sy.sql ;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class DataBaseConnection
{
//	private final String DBDRIVER	= "com.mysql.jdbc.Driver" ;
//	private final String DBURL		= "jdbc:mysql://localhost:3306/news" ;
//	private final String DBUSER		= "root" ;
//	private final String DBPASSWORD	= "hicc" ;
	private Connection conn			= null ;
//数据库连接
	public DataBaseConnection()
	{
		try
		{
//			Class.forName(DBDRIVER) ; 
			conn = DriverManager.getConnection("proxool.mysql") ;
		}
		catch (Exception e)
		{
			System.out.println(e) ;
		}
	}
//获取数据库连接
	public Connection getConnection()
	{
		return this.conn ;
	}
	public PreparedStatement getSql(String sql){
		PreparedStatement pstmt	= null ;
		try {
			pstmt = getConnection().prepareStatement(sql);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return pstmt;
	}
	
//关闭数据库连接
	public void close()
	{
		try
		{
			this.conn.close() ;			
		}
		catch (Exception e)
		{
		}
	}
};
